home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS26.ADF / SoundScape / AztecExamples / skeleton.c < prev    next >
C/C++ Source or Header  |  1989-01-26  |  3KB  |  140 lines

  1. /*    SKELETON.C    Skeleton module for Aztec C.
  2.  
  3.     (c) 1987    Todor Fay
  4. */
  5.  
  6. #include "exec/exec.h"
  7. #include "exec/types.h"
  8. #include "soundscape.h"
  9. #include "intuition/intuition.h"
  10.  
  11. /*    Images for input and output icons of the module.  */
  12.  
  13. extern struct Image *inimage, *outimage;
  14.  
  15. /*    Define your own state structure for edit routines. */
  16.  
  17. struct State {
  18.     long length;        /* Always has a length field first. */
  19.  
  20. /*    You supply remaining fields. */
  21.  
  22. };
  23.  
  24. /*    Declare a state structure. */
  25.  
  26. struct State state = { sizeof(state) - 4, };
  27.  
  28. /*    Pick an ID for your port, and a name. * /
  29.  
  30. #define PORT_ID        255
  31. #define PORT_NAME    "myportname"
  32.  
  33. /*    The id for this port, returned by AddMidiPort: */
  34.  
  35. short thisport;
  36.  
  37. /*    Base Pointers to SoundScape and Intuition */
  38.  
  39. long SoundScapeBase;
  40. long IntuitionBase;
  41.  
  42. outcode(note)
  43.  
  44. /*    This is your output routine.  It is called by the packet
  45.     router whenever it has a MIDI event for you.  Do something
  46.     with the event, then return.
  47.     Note the use of enteraztec() and leaveaztec().
  48. */
  49.  
  50. struct Note *note;
  51.  
  52. {
  53.     enteraztec();
  54.     FreeNode(note);
  55.     leaveaztec();
  56. }
  57.  
  58. opencode(direction)
  59.  
  60. /*    Depending on the direction, open the module for operation.
  61.     Return 1 if successful, 0 if not.  
  62. */
  63.  
  64. char direction;
  65.  
  66. {
  67.     enteraztec();
  68.     if (direction) {
  69.     /*  Code to init for sending events. */
  70.     }
  71.     else {
  72.     /*  Code to init for receiving events. */
  73.     }
  74.     leaveaztec();
  75.     return(1);
  76. }
  77.  
  78. closecode(direction)
  79.  
  80.     enteraztec();
  81.     if (direction) {
  82.     /*  Code to close down sending events. */
  83.     }
  84.     else {
  85.     /*  Code to take care of stopping receiving events. */
  86.     }
  87.     leaveaztec();
  88.     return(1);
  89. }
  90.  
  91. editcode(direction,command,buffer);
  92.  
  93. char direction;
  94. char command;
  95. struct State *buffer;
  96.  
  97. {
  98.     enteraztec();
  99.     switch (command) {
  100.     case USEREDIT :
  101.         if (direction) {
  102.     /*    Your edit routine for left icon here. */
  103.         }
  104.         else {
  105.     /*    Your edit routine for right icon here. */
  106.         }
  107.         break;
  108.     case SAVESTATE :
  109.     /*     Your routine to save to a file here. */
  110.     case GETSTATE :
  111.         movmem(&state,buffer,sizeof(state));
  112.         break;
  113.     case LOADSTATE :
  114.         movmem(buffer,&state,sizeof(state));
  115.         state.length = (sizeof(state) - 4);
  116.     /*    Your routine to load a file here. */
  117.         break;
  118.     case SETSTATE :
  119.         movmem(buffer,&state,sizeof(state));
  120.         state.length = (sizeof(state) - 4);
  121.         break;
  122.     }
  123.     leaveaztec();
  124. }
  125.  
  126.  
  127. main() {
  128.     IntuitionBase = OpenLibrary("intuition.library",0);
  129.     SoundScapeBase = OpenLibrary("soundscape.library",0);
  130.     if (SoundScapeBase) {
  131.     CloseLibrary(SoundScapeBase);
  132.     thisport = AddMidiPort(opencode,closecode,editcode,outcode,
  133.         &inimage,&outimage,PORT_ID,PORT_NAME);
  134.     SetTaskPri(FindTask(0),-20);
  135.     while (MidiPort(thisport)) Delay(100);
  136.     }
  137.     CloseLibrary(IntuitionBase);
  138. }
  139.